<?php
namespace app\en\Controller;
use think\View;
use think\Controller;
use app\en\model\Banner;
use app\en\model\Articles;
use app\en\model\News;
class Index extends Controller
{
    public function index(){
        //Banner 查询
        $banner = new Banner();
        $news = new News();
        $articles = new Articles();
        $banner_where = 'isuse =1';
        $news_where = ' 1=1 ';
        $articles_where = ' 1=1 ';
        $banner_list = $banner->getBannerByWhere($banner_where);
        $news_list = $news->getNewsByWhere($news_where);
        $articles_list = $articles->getArticlesByWhere($articles_where);
        $this->assign([
            'banner_list' => $banner_list,
            'news_list' => $news_list,
            'articles_list' => $articles_list,
        ]);
        return $this->fetch('index');
    }
    public function about_us(){
        $view = new View();
        return $view->fetch('about_us');
    }

    public function inv_project(){
        $articles = new Articles();
        $type = input('t') ?? 0;

        $articles_where = ' is_show=1 ';
        if($type){
            $articles_where .= ' and type = '.$type;
        }
        $articles_list = $articles->getArticlesByWhere($articles_where);
        $this->assign([
            'articles_list' => $articles_list,
            't' => $type,
        ]);
        return $this->fetch('inv_project');
    }

    public function link_us(){
        $view = new View();
        return $view->fetch('link_us');
    }
    public function news(){
        $view = new View();
        return $view->fetch('news');
    }
    public function news_detail(){
        $id = input('n');
        $news_m = new News();
        $news = $news_m->getNewsById($id) ?? [];
        if(!$news){
           return $this->redirect(url('news'));
        }
        $this->assign([
            'id'=>$id,
            'news'=>$news,
        ]);
        return $this->fetch('news_detail');
    }
    public function team_info(){
        $view = new View();
        return $view->fetch('team_info');
    }

}
